package com.xf.common.core.utils;

import ma.glasnost.orika.MapperFacade;
import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.impl.DefaultMapperFactory;

import java.util.Collection;
import java.util.List;

/**
 * @Description
 * @Author FengYi
 * @Date 2020-07-06 11:14
 */
public class DmpBeanUtil {
    /**
     * 默认字段工厂
     */
    public static final MapperFactory MAPPER_FACTORY = new DefaultMapperFactory.Builder().build();
    /**
     * 默认字段示例
     */
    public static final MapperFacade MAPPER_FACADE = MAPPER_FACTORY.getMapperFacade();


    public static <T> T map(Object source, Class<T> toClass) {
        return MAPPER_FACADE.map(source, toClass);
    }

    /**
     *
     * @param data 源数据
     * @param toClass 目标Class
     * @return
     */
    public static <T, S> List<T> mapAsList(Collection<S> data, Class<T> toClass) {
        return MAPPER_FACADE.mapAsList(data, toClass);
    }
}